<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>专家管理系统 - 数据管理</title>
    <#include "../../include/head-file.ftl"/>
    <link rel="stylesheet" href="${base}/static/ms-admin/4.7.2/css/index.css">
    <style>
        .ms-admin-data-container {
            height: calc(100vh - 60px);
        }

        .ms-container {
            padding: 0;
            background: transparent;
        }

        .ms-header {
            padding: 15px;
            margin-bottom: 15px;
            background-color: #fff;
            display: flex;
            align-items: center;
            justify-content: space-between;
            box-shadow: 0 1px 4px rgba(0,0,0,.1);
            border-radius: 4px;
        }

        .ms-header-left {
            display: flex;
            align-items: center;
        }

        .ms-header-title {
            font-size: 20px;
            font-weight: 600;
            color: #303133;
            margin: 0;
            position: relative;
            padding-left: 16px;
            display: flex;
            align-items: center;
        }

        .ms-header-title:before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 22px;
            background: linear-gradient(to bottom, #409EFF, #67c23a);
            border-radius: 2px;
        }

        .ms-header-subtitle {
            color: #909399;
            font-size: 14px;
            font-weight: normal;
            margin-left: 15px;
            font-style: italic;
            opacity: 0.9;
        }

        .operation-buttons {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .data-table-container {
            background: #fff;
            border-radius: 4px;
            padding: 20px;
            margin-bottom: 20px;
            box-shadow: 0 1px 4px rgba(0,0,0,.1);
        }

        .search-bar {
            margin-bottom: 20px;
            display: flex;
            align-items: center;
        }

        .back-button {
            margin-right: 20px;
        }

        .el-table .operation-cell .cell {
            display: flex;
            justify-content: center;
        }

        .el-pagination {
            text-align: right;
            margin-top: 15px;
        }

        .delete-confirm-content {
            display: flex;
            align-items: center;
        }

        .el-button--primary {
            background-color: #409EFF;
            border-color: #409EFF;
        }

        .el-button--danger {
            background-color: #F56C6C;
            border-color: #F56C6C;
            color: #fff;
        }

        /* 优化标签页样式 */
        .el-tabs--card > .el-tabs__header {
            border-bottom: 1px solid #EBEEF5;
            margin-bottom: 0;
        }

        .el-tabs--card > .el-tabs__header .el-tabs__nav {
            border: none;
        }

        .el-tabs__item {
            font-size: 14px;
            height: 40px;
            line-height: 40px;
            padding: 0 20px;
            transition: all 0.3s;
            color: #606266;
            border: 1px solid transparent;
            border-bottom: none;
            margin-right: 5px;
            border-radius: 4px 4px 0 0;
        }

        .el-tabs--card > .el-tabs__header .el-tabs__item {
            border-left: 1px solid #EBEEF5;
            border-right: 1px solid #EBEEF5;
            border-top: 1px solid #EBEEF5;
            background-color: #F5F7FA;
        }

        .el-tabs--card > .el-tabs__header .el-tabs__item:first-child {
            border-left: 1px solid #EBEEF5;
        }

        .el-tabs--card > .el-tabs__header .el-tabs__item.is-active {
            background-color: #fff;
            border-bottom-color: #fff;
            color: #409EFF;
            font-weight: 500;
            border-top: 2px solid #409EFF;
        }

        .el-tabs--card > .el-tabs__header .el-tabs__item:hover {
            color: #409EFF;
        }
    </style>
</head>
<body>
<div id="app" class="ms-admin-data-container" v-cloak>
    <div class="ms-header">
        <div class="ms-header-left">
            <h1 class="ms-header-title">
                数据管理
            </h1>
            <span class="ms-header-subtitle">管理专家、项目、企业数据</span>
        </div>
        <div class="operation-buttons">
            <el-button class="back-button" @click="goBack">返回</el-button>
        </div>
    </div>

    <el-main class="ms-container">
        <el-tabs v-model="activeTab" type="card" @tab-click="handleTabClick">
            <el-tab-pane label="专家信息管理" name="expert">
                <div class="data-table-container">
                    <div class="search-bar">
                        <el-input
                            v-model="expertSearchKeyword"
                            placeholder="输入专家姓名、编号或研究方向搜索"
                            style="width: 300px;"
                            clearable>
                        </el-input>
                        <el-button type="primary" @click="searchExpert" style="margin-left: 10px;">搜索</el-button>
                        <el-button @click="resetExpertSearch" style="margin-left: 10px;">重置</el-button>
                    </div>

                    <el-table
                        :data="expertList"
                        v-loading="expertLoading"
                        stripe
                        border
                        style="width: 100%">
                        <el-table-column prop="expertCode" label="专家编号" width="110"></el-table-column>
                        <el-table-column prop="name" label="专家姓名" width="110"></el-table-column>
                        <el-table-column prop="college" label="所属学院" width="160"></el-table-column>
                        <el-table-column prop="researchKeywords" label="研究方向" min-width="220" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="title" label="职称" width="110"></el-table-column>
                        <el-table-column label="操作" width="180" align="center" class-name="operation-cell">
                            <template #default="scope">
                                <el-button size="small" type="text" @click="editExpert(scope.row)">编辑</el-button>
                                <el-button size="small" type="text" style="color: #F56C6C;" @click="deleteExpert(scope.row)">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>

                    <!-- 分页组件 -->
                    <div style="text-align: right; display: flex; justify-content: end;">
                        <el-pagination
                            @size-change="handleExpertSizeChange"
                            @current-change="handleExpertCurrentChange"
                            :current-page="expertPagination.pageNo"
                            :page-sizes="[5, 10, 20, 50]"
                            :page-size="expertPagination.pageSize"
                            layout="total, sizes, prev, pager, next, jumper"
                            :total="expertPagination.total"
                        style="">
                        </el-pagination>
                    </div>
                </div>

            </el-tab-pane>

            <el-tab-pane label="项目信息管理" name="project">
                <div class="data-table-container">
                    <div class="search-bar">
                        <el-input
                            v-model="projectSearchKeyword"
                            placeholder="输入项目名称、编号或技术关键词搜索"
                            style="width: 300px;"
                            clearable>
                        </el-input>
                        <el-button type="primary" @click="searchProject" style="margin-left: 10px;">搜索</el-button>
                        <el-button @click="resetProjectSearch" style="margin-left: 10px;">重置</el-button>
                    </div>

                    <el-table
                        :data="projectList"
                        v-loading="projectLoading"
                        stripe
                        border
                        style="width: 100%">
                        <el-table-column prop="projectCode" label="项目编号" width="110"></el-table-column>
                        <el-table-column prop="projectName" label="项目名称" min-width="180"></el-table-column>
                        <el-table-column prop="department" label="所属部门" width="120"></el-table-column>
                        <el-table-column prop="projectType" label="项目类型" width="100"></el-table-column>
                        <el-table-column prop="leaderCode" label="负责人" width="100"></el-table-column>
                        <el-table-column prop="techMaturity" label="技术成熟度" width="120"></el-table-column>
                        <el-table-column label="操作" width="180" align="center" class-name="operation-cell">
                            <template #default="scope">
                                <el-button size="small" type="text" @click="editProject(scope.row)">编辑</el-button>
                                <el-button size="small" type="text" style="color: #F56C6C;" @click="deleteProject(scope.row)">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>

                    <!-- 分页组件 -->
                    <div style="text-align: right; display: flex; justify-content: end;">
                        <el-pagination
                            @size-change="handleProjectSizeChange"
                            @current-change="handleProjectCurrentChange"
                            :current-page="projectPagination.pageNo"
                            :page-sizes="[5, 10, 20, 50]"
                            :page-size="projectPagination.pageSize"
                            layout="total, sizes, prev, pager, next, jumper"
                            :total="projectPagination.total">
                        </el-pagination>
                    </div>
                </div>
            </el-tab-pane>

            <el-tab-pane label="企业信息管理" name="company">
                <div class="data-table-container">
                    <div class="search-bar">
                        <el-input
                            v-model="companySearchKeyword"
                            placeholder="输入企业名称或编号搜索"
                            style="width: 300px;"
                            clearable>
                        </el-input>
                        <el-button type="primary" @click="searchCompany" style="margin-left: 10px;">搜索</el-button>
                        <el-button @click="resetCompanySearch" style="margin-left: 10px;">重置</el-button>
                    </div>

                    <el-table
                        :data="companyList"
                        v-loading="companyLoading"
                        stripe
                        border
                        style="width: 100%">
                        <el-table-column prop="companyCode" label="企业编号" width="120"></el-table-column>
                        <el-table-column prop="companyName" label="企业名称" min-width="180"></el-table-column>
                        <el-table-column prop="companyType" label="企业类型" width="120"></el-table-column>
                        <el-table-column prop="industryPrimary" label="所属行业" width="120"></el-table-column>
                        <el-table-column prop="contactPerson" label="联系人" width="100"></el-table-column>
                        <el-table-column prop="contactInfo" label="联系方式" width="150"></el-table-column>
                        <el-table-column label="操作" width="180" align="center" class-name="operation-cell">
                            <template #default="scope">
                                <el-button size="small" type="text" @click="editCompany(scope.row)">编辑</el-button>
                                <el-button size="small" type="text" style="color: #F56C6C;" @click="deleteCompany(scope.row)">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>

                    <!-- 分页组件 -->
                    <div style="text-align: right; display: flex; justify-content: end;">
                        <el-pagination
                            @size-change="handleCompanySizeChange"
                            @current-change="handleCompanyCurrentChange"
                            :current-page="companyPagination.pageNo"
                            :page-sizes="[5, 10, 20, 50]"
                            :page-size="companyPagination.pageSize"
                            layout="total, sizes, prev, pager, next, jumper"
                            :total="companyPagination.total">
                        </el-pagination>
                    </div>
                </div>
            </el-tab-pane>
        </el-tabs>
    </el-main>

    <!-- 编辑专家对话框 -->
    <el-dialog
        title="编辑专家信息"
        :visible.sync="editExpertDialogVisible"
        v-model="editExpertDialogVisible"
        width="80%"
        :close-on-click-modal="false">
        <el-form :model="currentExpert" ref="expertForm" label-width="120px" :rules="expertFormRules">
            <el-row :gutter="20">
                <el-col :span="8">
                    <el-form-item label="专家编号">
                        <el-input v-model="currentExpert.expertCode" disabled></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="姓名">
                        <el-input v-model="currentExpert.name"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="性别">
                        <el-select v-model="currentExpert.gender" placeholder="请选择">
                            <el-option label="男" value="男"></el-option>
                            <el-option label="女" value="女"></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row :gutter="20">
                <el-col :span="8">
                    <el-form-item label="年龄">
                        <el-input-number v-model="currentExpert.age" :min="0" :max="120"></el-input-number>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="职称/头衔">
                        <el-input v-model="currentExpert.title"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="最高学历">
                        <el-select v-model="currentExpert.highestEducation" placeholder="请选择">
                            <el-option label="博士" value="博士"></el-option>
                            <el-option label="硕士" value="硕士"></el-option>
                            <el-option label="本科" value="本科"></el-option>
                            <el-option label="其他" value="其他"></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row :gutter="20">
                <el-col :span="8">
                    <el-form-item label="一级学科">
                        <el-input v-model="currentExpert.firstLevelDiscipline"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="二级学科">
                        <el-input v-model="currentExpert.secondLevelDiscipline"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="校内/外标识">
                        <el-select v-model="currentExpert.insideOutside" placeholder="请选择">
                            <el-option label="校内" value="校内"></el-option>
                            <el-option label="校外" value="校外"></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row :gutter="20">
                <el-col :span="8">
                    <el-form-item label="所属学院">
                        <el-input v-model="currentExpert.college"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="知识产权持有量">
                        <el-input v-model="currentExpert.ipOwnership"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="社会职务">
                        <el-input v-model="currentExpert.socialPositions"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row :gutter="20">
                <el-col :span="12">
                    <el-form-item label="纵向项目数">
                        <el-input v-model="currentExpert.verticalProjects"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="横向项目数">
                        <el-input v-model="currentExpert.horizontalProjects"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row :gutter="20">
                <el-col :span="12">
                    <el-form-item label="研究方向关键词">
                        <el-input v-model="currentExpert.researchKeywords" type="textarea" :rows="2" placeholder="请输入3-5个关键词"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="代表性成果类型">
                        <el-input v-model="currentExpert.achievementType"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-form-item label="联系方式">
                <el-input v-model="currentExpert.contact"></el-input>
            </el-form-item>
            <el-form-item label="研究方向" prop="researchKeywords">
                <el-input v-model="currentExpert.researchKeywords" type="textarea" rows="2"></el-input>
            </el-form-item>
            <el-form-item label="备注" prop="remarks">
                <el-input v-model="currentExpert.remarks" type="textarea" rows="3"></el-input>
            </el-form-item>
        </el-form>
        <template #footer>
            <span class="dialog-footer">
                <el-button @click="editExpertDialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="saveExpert" :loading="saveLoading">保 存</el-button>
            </span>
        </template>
    </el-dialog>

    <!-- 编辑项目对话框 -->
    <el-dialog
        title="编辑项目信息"
        :visible.sync="editProjectDialogVisible"
        v-model="editProjectDialogVisible"
        width="80%"
        :close-on-click-modal="false">
        <el-form :model="currentProject" ref="projectForm" label-width="120px" :rules="projectFormRules">
            <el-row :gutter="20">
                <el-col :span="8">
                    <el-form-item label="项目编号">
                        <el-input v-model="currentProject.projectCode" disabled></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="项目名称">
                        <el-input v-model="currentProject.projectName"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="所属部门">
                        <el-input v-model="currentProject.department"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row :gutter="20">
                <el-col :span="8">
                    <el-form-item label="负责人编号">
                        <el-input v-model="currentProject.leaderCode"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="项目类型">
                        <el-input v-model="currentProject.projectType"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="技术成熟度">
                        <el-input v-model="currentProject.techMaturity"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row :gutter="20">
                <el-col :span="8">
                    <el-form-item label="参与专家">
                        <el-input v-model="currentProject.participantExperts"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="市场化阶段">
                        <el-input v-model="currentProject.marketStage"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="转化方式">
                        <el-input v-model="currentProject.transformationMode"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row :gutter="20">
                <el-col :span="8">
                    <el-form-item label="核心技术关键词">
                        <el-input v-model="currentProject.coreTechKeywords"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="应用行业">
                        <el-input v-model="currentProject.applicationIndustry"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="预算需求">
                        <el-input v-model="currentProject.budget"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row :gutter="20">
                <el-col :span="12">
                    <el-form-item label="合作企业意向">
                        <el-input v-model="currentProject.cooperationTendency"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="联系方式">
                        <el-input v-model="currentProject.contact"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-form-item label="知识产权详情">
                <el-input v-model="currentProject.ipDetails"></el-input>
            </el-form-item>

            <el-form-item label="核心技术关键词" prop="coreTechKeywords">
                <el-input v-model="currentProject.coreTechKeywords" type="textarea" rows="2"></el-input>
            </el-form-item>
            <el-form-item label="备注" prop="remarks">
                <el-input v-model="currentProject.remarks" type="textarea" rows="3"></el-input>
            </el-form-item>
        </el-form>
        <template #footer>
            <span class="dialog-footer">
                <el-button @click="editProjectDialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="saveProject" :loading="saveLoading">保 存</el-button>
            </span>
        </template>
    </el-dialog>

    <!-- 编辑企业对话框 -->
    <el-dialog
        title="编辑企业信息"
        :visible.sync="editCompanyDialogVisible"
        v-model="editCompanyDialogVisible"
        width="80%"
        :close-on-click-modal="false">
        <el-form :model="currentCompany" ref="companyForm" label-width="120px" :rules="companyFormRules">
            <el-row :gutter="20">
                <el-col :span="8">
                    <el-form-item label="企业编号">
                        <el-input v-model="currentCompany.companyCode" disabled></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="企业名称">
                        <el-input v-model="currentCompany.companyName"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="企业类型">
                        <el-input v-model="currentCompany.companyType"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row :gutter="20">
                <el-col :span="8">
                    <el-form-item label="所属行业(一级)">
                        <el-input v-model="currentCompany.industryPrimary"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="所属行业(二级)">
                        <el-input v-model="currentCompany.industrySecondary"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="注册地址">
                        <el-input v-model="currentCompany.registrationAddress"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row :gutter="20">
                <el-col :span="8">
                    <el-form-item label="联系人">
                        <el-input v-model="currentCompany.contactPerson"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="联系方式">
                        <el-input v-model="currentCompany.contactInfo"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="合作状态">
                        <el-input v-model="currentCompany.cooperationStatus"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row :gutter="20">
                <el-col :span="8">
                    <el-form-item label="主营业务关键词">
                        <el-input v-model="currentCompany.businessKeywords"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="合作需求类型">
                        <el-input v-model="currentCompany.cooperationType"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="需求技术领域">
                        <el-input v-model="currentCompany.requiredTechField"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row :gutter="20">
                <el-col :span="12">
                    <el-form-item label="需求专家职称">
                        <el-input v-model="currentCompany.requiredExpertTitle"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="对接专家编号">
                        <el-input v-model="currentCompany.matchedExpertCodes"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row :gutter="20">
                <el-col :span="24">
                    <el-form-item label="合作历史项目">
                        <el-input v-model="currentCompany.cooperationHistory"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-form-item label="主营业务关键词" prop="businessKeywords">
                <el-input v-model="currentCompany.businessKeywords" type="textarea" rows="2"></el-input>
            </el-form-item>
            <el-form-item label="备注" prop="remarks">
                <el-input v-model="currentCompany.remarks" type="textarea" rows="3"></el-input>
            </el-form-item>
        </el-form>
        <template #footer>
            <span class="dialog-footer">
                <el-button @click="editCompanyDialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="saveCompany" :loading="saveLoading">保 存</el-button>
            </span>
        </template>
    </el-dialog>

    <!-- 删除确认对话框 -->
    <el-dialog
        title="删除确认"
        :visible.sync="deleteDialogVisible"
        v-model="deleteDialogVisible"
        width="30%"
        id="deleteDialog"
        :close-on-click-modal="false">
        <div class="delete-confirm-content">
            <i class="el-icon-warning" style="color: #E6A23C; font-size: 24px; margin-right: 10px;"></i>
            <span>确定要删除该条{{ deleteType === 'company' ? '企业' : (deleteType === 'expert' ? '专家' : '项目') }}信息吗？</span>
        </div>
        <div class="delete-confirm-detail" style="margin-top: 20px; color: #F56C6C;">
            此操作不可恢复，请谨慎操作！
        </div>
        <template #footer>
            <span class="dialog-footer">
                <el-button @click="deleteDialogVisible = false">取 消</el-button>
                <el-button type="danger" @click="confirmDelete()" :loading="deleteLoading">确定删除</el-button>
            </span>
        </template>
    </el-dialog>
</div>

<script>
    "use strict"
    var managementVue = new _Vue({
        el: '#app',
        data: function () {
            return {
                // 标签页
                activeTab: 'expert',

                // 专家数据
                expertList: [],
                expertLoading: false,
                expertSearchKeyword: '',
                expertPagination: {
                    pageNo: 1,
                    pageSize: 10,
                    total: 0
                },

                // 项目数据
                projectList: [],
                projectLoading: false,
                projectSearchKeyword: '',
                projectPagination: {
                    pageNo: 1,
                    pageSize: 10,
                    total: 0
                },

                // 企业数据
                companyList: [],
                companyLoading: false,
                companySearchKeyword: '',
                companyPagination: {
                    pageNo: 1,
                    pageSize: 10,
                    total: 0
                },

                // 编辑对话框
                editExpertDialogVisible: false,
                editProjectDialogVisible: false,
                editCompanyDialogVisible: false,

                // 当前编辑对象
                currentExpert: {},
                currentProject: {},
                currentCompany: {},

                // 删除对话框
                deleteDialogVisible: false,
                deleteType: '',
                deleteLoading: false,
                deleteItemId: '',

                // 表单规则
                expertFormRules: {
                    name: [
                        { required: true, message: '请输入专家姓名', trigger: 'blur' }
                    ],
                    college: [
                        { required: true, message: '请输入所属学院', trigger: 'blur' }
                    ]
                },
                projectFormRules: {
                    projectName: [
                        { required: true, message: '请输入项目名称', trigger: 'blur' }
                    ],
                    leaderCode: [
                        { required: true, message: '请输入负责人编号', trigger: 'blur' }
                    ]
                },
                companyFormRules: {
                    companyName: [
                        { required: true, message: '请输入企业名称', trigger: 'blur' }
                    ],
                    companyType: [
                        { required: true, message: '请输入企业类型', trigger: 'blur' }
                    ]
                },

                saveLoading: false
            };
        },
        methods: {
            // 返回上一页
            goBack: function() {
                window.location.href = ms.manager + "/expertmanage/relation/index";
            },

            // 处理标签页切换
            handleTabClick: function(tab) {
                this.activeTab = tab.name;
                if (tab.name === 'expert') {
                    this.searchExpert();
                } else if (tab.name === 'project') {
                    this.searchProject();
                } else if (tab.name === 'company') {
                    this.searchCompany();
                }
            },

            // ========== 专家相关方法 ==========
            searchExpert: function() {
                this.expertLoading = true;
                var that = this;
                var url = ms.manager + "/expertmanage/expert/list";

                // 构建请求参数
                var params = new URLSearchParams();
                params.append('pageNum', that.expertPagination.pageNo);
                params.append('pageSize', that.expertPagination.pageSize);

                if (that.expertSearchKeyword) {
                    params.append('keyword', that.expertSearchKeyword);
                }


                ms.http.get(url + "?" + params.toString()).then(function (res) {
                    that.expertLoading = false;
                    if (res.result && res.data) {
                        that.expertList = res.data.records || [];
                        that.expertPagination.pageNo = parseInt(res.data.current) || 1;
                        that.expertPagination.pageSize = parseInt(res.data.size) || 5;
                        that.expertPagination.total = parseInt(res.data.total) || 0;

                    } else {
                        that.$notify.error({
                            title: '错误',
                            message: res.msg || '获取专家列表失败'
                        });
                    }
                }).catch(function(err) {
                    that.expertLoading = false;
                    that.$notify.error({
                        title: '错误',
                        message: '获取专家列表失败：' + err
                    });
                });
            },
            resetExpertSearch: function() {
                this.expertSearchKeyword = '';
                this.expertPagination.pageNo = 1;
                this.searchExpert();
            },
            handleExpertSizeChange: function(size) {
                this.expertPagination.pageSize = size;
                this.searchExpert();
            },
            handleExpertCurrentChange: function(page) {
                this.expertPagination.pageNo = page;
                this.searchExpert();
            },
            editExpert: function(row) {
                this.currentExpert = JSON.parse(JSON.stringify(row)); // 深拷贝
                this.editExpertDialogVisible = true;
            },
            deleteExpert: function(row) {
                if (!row || !row.expertCode) {
                    this.$notify.error({
                        title: '错误',
                        message: '无效的专家数据',
                        duration: 3000
                    });
                    return;
                }

                this.currentExpert = row;
                this.deleteType = 'expert';
                this.deleteItemId = row.expertCode;
                this.deleteDialogVisible = true;
            },
            saveExpert: function() {
                if (!this.currentExpert || !this.currentExpert.expertCode) {
                    this.$notify.error({
                        title: '错误',
                        message: '专家数据不完整',
                        duration: 3000
                    });
                    return;
                }

                var that = this;
                this.$refs.expertForm.validate(function(valid) {
                    if (valid) {
                        that.saveLoading = true;
                        var url = ms.manager + "/expertmanage/expert/update";
                        console.log("发送专家更新请求: ", that.currentExpert);

                        ms.http.post(url, that.currentExpert).then(function (res) {
                            that.saveLoading = false;
                            if (res.result) {
                                that.$notify.success({
                                    title: '成功',
                                    message: '专家信息更新成功',
                                    duration: 3000
                                });
                                that.editExpertDialogVisible = false;
                                that.searchExpert();
                            } else {
                                that.$notify.error({
                                    title: '更新失败',
                                    message: res.msg || '专家信息更新失败，请稍后重试',
                                    duration: 5000
                                });
                            }
                        }).catch(function(err) {
                            that.saveLoading = false;
                            that.$notify.error({
                                title: '系统错误',
                                message: '更新过程中发生错误：' + err,
                                duration: 5000
                            });
                        });
                    } else {
                        that.$notify.warning({
                            title: '表单验证失败',
                            message: '请检查并完善表单信息',
                            duration: 3000
                        });
                    }
                });
            },

            // ========== 项目相关方法 ==========
            searchProject: function() {
                this.projectLoading = true;
                var that = this;
                var url = ms.manager + "/expertmanage/project/list";
                
                // 构建请求参数
                var params = new URLSearchParams();
                params.append('pageNum', that.projectPagination.pageNo);
                params.append('pageSize', that.projectPagination.pageSize);
                
                if (that.projectSearchKeyword) {
                    params.append('keyword', that.projectSearchKeyword);
                }
                
                ms.http.get(url + "?" + params.toString()).then(function (res) {
                    that.projectLoading = false;
                    if (res.result && res.data) {
                        that.projectList = res.data.records || [];
                        that.projectPagination.pageNo = parseInt(res.data.current) || 1;
                        that.projectPagination.pageSize = parseInt(res.data.size) || 5;
                        that.projectPagination.total = parseInt(res.data.total) || 0;
                    } else {
                        that.$notify.error({
                            title: '错误',
                            message: res.msg || '获取项目列表失败'
                        });
                    }
                }).catch(function(err) {
                    that.projectLoading = false;
                    that.$notify.error({
                        title: '错误',
                        message: '获取项目列表失败：' + err
                    });
                });
            },
            resetProjectSearch: function() {
                this.projectSearchKeyword = '';
                this.projectPagination.pageNo = 1;
                this.searchProject();
            },
            handleProjectSizeChange: function(size) {
                this.projectPagination.pageSize = size;
                this.searchProject();
            },
            handleProjectCurrentChange: function(page) {
                this.projectPagination.pageNo = page;
                this.searchProject();
            },
            editProject: function(row) {
                this.currentProject = JSON.parse(JSON.stringify(row)); // 深拷贝
                this.editProjectDialogVisible = true;
            },
            deleteProject: function(row) {
                if (!row || !row.projectCode) {
                    this.$notify.error({
                        title: '错误',
                        message: '无效的项目数据',
                        duration: 3000
                    });
                    return;
                }

                this.currentProject = row;
                this.deleteType = 'project';
                this.deleteItemId = row.projectCode;
                this.deleteDialogVisible = true;
            },
            saveProject: function() {
                if (!this.currentProject || !this.currentProject.projectCode) {
                    this.$notify.error({
                        title: '错误',
                        message: '项目数据不完整',
                        duration: 3000
                    });
                    return;
                }

                var that = this;
                this.$refs.projectForm.validate(function(valid) {
                    if (valid) {
                        that.saveLoading = true;
                        var url = ms.manager + "/expertmanage/project/update";
                        console.log("发送项目更新请求: ", that.currentProject);

                        ms.http.post(url, that.currentProject).then(function (res) {
                            that.saveLoading = false;
                            if (res.result) {
                                that.$notify.success({
                                    title: '成功',
                                    message: '项目信息更新成功',
                                    duration: 3000
                                });
                                that.editProjectDialogVisible = false;
                                that.searchProject();
                            } else {
                                that.$notify.error({
                                    title: '更新失败',
                                    message: res.msg || '项目信息更新失败，请稍后重试',
                                    duration: 5000
                                });
                            }
                        }).catch(function(err) {
                            that.saveLoading = false;
                            that.$notify.error({
                                title: '系统错误',
                                message: '更新过程中发生错误：' + err,
                                duration: 5000
                            });
                        });
                    } else {
                        that.$notify.warning({
                            title: '表单验证失败',
                            message: '请检查并完善表单信息',
                            duration: 3000
                        });
                    }
                });
            },

            // ========== 企业相关方法 ==========
            searchCompany: function() {
                this.companyLoading = true;
                var that = this;
                var url = ms.manager + "/expertmanage/company/list";
                
                // 构建请求参数
                var params = new URLSearchParams();
                params.append('pageNum', that.companyPagination.pageNo);
                params.append('pageSize', that.companyPagination.pageSize);
                
                if (that.companySearchKeyword) {
                    params.append('keyword', that.companySearchKeyword);
                }
                
                ms.http.get(url + "?" + params.toString()).then(function (res) {
                    that.companyLoading = false;
                    if (res.result && res.data) {
                        that.companyList = res.data.records || [];
                        that.companyPagination.pageNo = parseInt(res.data.current) || 1;
                        that.companyPagination.pageSize = parseInt(res.data.size) || 5;
                        that.companyPagination.total = parseInt(res.data.total) || 0;
                    } else {
                        that.$notify.error({
                            title: '错误',
                            message: res.msg || '获取企业列表失败'
                        });
                    }
                }).catch(function(err) {
                    that.companyLoading = false;
                    that.$notify.error({
                        title: '错误',
                        message: '获取企业列表失败：' + err
                    });
                });
            },
            resetCompanySearch: function() {
                this.companySearchKeyword = '';
                this.companyPagination.pageNo = 1;
                this.searchCompany();
            },
            handleCompanySizeChange: function(size) {
                this.companyPagination.pageSize = size;
                this.searchCompany();
            },
            handleCompanyCurrentChange: function(page) {
                this.companyPagination.pageNo = page;
                this.searchCompany();
            },
            editCompany: function(row) {
                this.currentCompany = JSON.parse(JSON.stringify(row)); // 深拷贝
                this.editCompanyDialogVisible = true;
            },
            deleteCompany: function(row) {
                if (!row || !row.companyCode) {
                    this.$notify.error({
                        title: '错误',
                        message: '无效的企业数据',
                        duration: 3000
                    });
                    return;
                }

                this.currentCompany = row;
                this.deleteType = 'company';
                this.deleteItemId = row.companyCode;
                this.deleteDialogVisible = true;
            },
            saveCompany: function() {
                if (!this.currentCompany || !this.currentCompany.companyCode) {
                    this.$notify.error({
                        title: '错误',
                        message: '企业数据不完整',
                        duration: 3000
                    });
                    return;
                }

                var that = this;
                this.$refs.companyForm.validate(function(valid) {
                    if (valid) {
                        that.saveLoading = true;
                        var url = ms.manager + "/expertmanage/company/update";
                        console.log("发送企业更新请求: ", that.currentCompany);

                        ms.http.post(url, that.currentCompany).then(function (res) {
                            that.saveLoading = false;
                            if (res.result) {
                                that.$notify.success({
                                    title: '成功',
                                    message: '企业信息更新成功',
                                    duration: 3000
                                });
                                that.editCompanyDialogVisible = false;
                                that.searchCompany();
                            } else {
                                that.$notify.error({
                                    title: '更新失败',
                                    message: res.msg || '企业信息更新失败，请稍后重试',
                                    duration: 5000
                                });
                            }
                        }).catch(function(err) {
                            that.saveLoading = false;
                            that.$notify.error({
                                title: '系统错误',
                                message: '更新过程中发生错误：' + err,
                                duration: 5000
                            });
                        });
                    } else {
                        that.$notify.warning({
                            title: '表单验证失败',
                            message: '请检查并完善表单信息',
                            duration: 3000
                        });
                    }
                });
            },

            // ========== 删除操作 ==========
            confirmDelete: function() {
                if (!this.deleteItemId || !this.deleteType) {
                    this.$notify.error({
                        title: '错误',
                        message: '删除信息不完整',
                        duration: 3000
                    });
                    return;
                }

                this.deleteLoading = true;
                var that = this;

                var url = "";
                if (this.deleteType === 'company') {
                    url = ms.manager + "/expertmanage/company/delete/" + that.deleteItemId;
                } else if (this.deleteType === 'expert') {
                    url = ms.manager + "/expertmanage/expert/delete/" + that.deleteItemId;
                } else if (this.deleteType === 'project') {
                    url = ms.manager + "/expertmanage/project/deleteByCode/" + that.deleteItemId;
                } else {
                    this.deleteLoading = false;
                    this.$notify.error({
                        title: '错误',
                        message: '未知的数据类型: ' + this.deleteType,
                        duration: 3000
                    });
                    return;
                }

                ms.http.post(url).then(function(res) {
                    that.deleteLoading = false;
                    if (res.result) {
                        that.$notify({
                            title: '删除成功',
                            message: '已删除' + (that.deleteType === 'company' ? '企业' : (that.deleteType === 'expert' ? '专家' : '项目')) + '信息',
                            type: 'success',
                            duration: 3000
                        });
                        that.deleteDialogVisible = false;

                        // 刷新相应的列表
                        if (that.deleteType === 'company') {
                            that.searchCompany();
                        } else if (that.deleteType === 'expert') {
                            that.searchExpert();
                        } else if (that.deleteType === 'project') {
                            that.searchProject();
                        }
                    } else {
                        that.$notify.error({
                            title: '删除失败',
                            message: res.msg || '删除信息失败，请稍后重试',
                            duration: 5000
                        });
                        that.deleteDialogVisible = false;
                    }
                }).catch(function(err) {
                    that.deleteLoading = false;
                    that.$notify.error({
                        title: '系统错误',
                        message: '删除过程中发生错误：' + err,
                        duration: 5000
                    });
                    that.deleteDialogVisible = false;
                });
            },
            handleQueryRelations: function(expertCode) {
                // Redirect to the expert editing page
                var expert = this.expertList.find(function(item) {
                    return item.expertCode === expertCode;
                });
                if (expert) {
                    this.editExpert(expert);
                }
            },
            handleDeleteConfirm: function(row) {
                this.deleteExpert(row);
            }
        },
        mounted: function() {
            // 初始化加载所有标签页的数据
            this.searchExpert();
            this.searchProject();
            this.searchCompany();
        }
    });
</script>
</body>
</html>